﻿#NoEnv
#SingleInstance, Force
SetWorkingDir, %A_ScriptDir%
CoordMode, Mouse, Screen
SetTitleMatchMode, 1

OnMessage(0x200, "WM_MOUSEMOVE")


;___ Global Constants _____________________________________________________________________

global COBRA 			:= A_ScriptDir
global USER_SETTINGS 	:= A_ScriptDir "\user\user_settings.ini"
USER_FUNCTIONS 		 	:= "user\user_functions.ahk"
HOTSTRINGS     			:= "third_party\hotstrings\CustomHotstrings.ahk"
HSTXT          			:= "third_party\hotstrings\hstxt.ahk"
MGR_COMMANDS   			:= "third_party\mouse_gestures\Commands.ini"
MGR            			:= "third_party\mouse_gestures\MGR.ahk"
C0BRA_INFO     			:= "c0bra_info.ini"



GUI_SETTINGS 	:= A_ScriptDir "\config\Gui.ini"
HKEY_SETTINGS 	:= A_ScriptDir "\user\Hotkeys.ini"
USER_FUNCTIONS 	:= A_ScriptDir "\user\user_functions.ahk"
C0BRA_INFO 		:= A_ScriptDir "\c0bra_info.ini"

USER_INI 		:= new ini(USER_SETTINGS)

FileRead, VERSION, version



;{___  Tray Icon/Menu  ______________________________________________________________________________________

IniRead, Trigger, % USER_SETTINGS, MainHotkey, Hotkey

Menu, Tray, NoStandard
Menu, Tray, Icon, res\c0bra.ico

Menu, Sub, Add
Menu, Sub, DeleteAll
Menu, Sub, Add, Trigger: %Trigger%, TrayText
Menu, Sub, Disable, Trigger: %Trigger%
Menu, Sub, Add
Menu, Sub, Add, Version %version%, TrayText
Menu, Sub, Disable, Version %version%

Menu, Tray, Add, About, :Sub
Menu, Tray, Add
Menu, Tray, Add, Settings, MeSettings
Menu, Tray, Add
Menu, Tray, Add, Reload, ReloadMe
Menu, Tray, Add, Exit, closer
Menu, Tray, Default, Settings
Menu, Tray, tip, c0bra!
;}



;{___  Register Hotkeys  _________________________________________________________________________

	;{___  User Hotkeys  ___}

	SUPER_KEYS := USER_INI.Keys("UserHotkeys")
	loop, parse, SUPER_KEYS, `n, `r
		if ((thisHK := Trim(A_LoopField)) != "")
			Hotkey, %thisHK%, SUPER_SHORTS
	;}


	;{___  Main Hotkey  ___}

	mainHotkey := Trim(USER_INI.MainHotkey.Hotkey)	
	winList := Trim(USER_INI.MainHotkey.DisableIfActiveList)
	Loop, parse, winList, csv
		if ((thisWin := Trim(A_LoopField)) != "")
			GroupAdd, NoRunGroup, %thisWin%
	Hotkey, IfWinNotActive, ahk_group NoRunGroup
		Hotkey, % mainHotkey, MAIN_TRIGGER 
	Hotkey, ifwinactive,
	;}


	;{___  The Closer  ___}
	
	closerHK := Trim(USER_INI.TheCloser.Hotkey)
	winList := Trim(USER_INI.TheCloser.DisableIfActiveList)
	Loop, parse, winList, csv
	if ((thisWin := Trim(A_LoopField)) != "")
		GroupAdd, NoRunGroup, %thisWin%
	Hotkey, IfWinNotActive, ahk_group NoRunGroup
	Hotkey, %closerHK%, THE_CLOSER
	;}

;}


;___ Global Constants _____________________________________________________________________

#Include code\startup.ahk
#Include code\gui.ahk
#Include user\user_functions.ahk
#Include code\functions.ahk
#Include <Class_CTLCOLORS>
#Include <cIni>
#Include <ColorChooser>
			